package com.xzz.mybatis.generator.config;

import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import java.io.File;

/**
 * @author: hhz
 * @createDate: 2021-3-10
 */
@Configuration
public class MybatisPlusGeneratorConfig {
    /**
     * 全局配置
     */
    @Bean
    public GlobalConfig initGlobalConfig(){
        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.setAuthor("xzz");
        globalConfig.setOpen(false);
        File classFolder = new File(MybatisPlusGeneratorConfig.class.getResource("/").getFile());
        globalConfig.setOutputDir(classFolder.getParentFile().getAbsolutePath()+"/src");
        globalConfig.setServiceName("%sService");
        globalConfig.setDateType(DateType.ONLY_DATE);
        return globalConfig;
    }
    /**
     * 自定义配置项
     * @return InjectionConfig
     */
    @Bean
    public InjectionConfig injectionConfig(){
        return new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };
    }
}
